package com.assessment.utils;

import java.util.HashMap;
import java.util.Map;

import static com.assessment.utils.Constant.CODE_ERROR;
import static com.assessment.utils.Constant.CODE_SUCCESS;

public class OneReturn {
    private Integer code;
    private String msg;
    private Object data;

    // 构造方法
    public OneReturn() {
        this(CODE_ERROR, "ERROR", "");
    }

    public OneReturn(Integer code, String msg) {
        this(code, msg, "");
    }

    public OneReturn(Object data) {
        this(CODE_SUCCESS, "SUCCESS", data);
    }

    public OneReturn(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    // 获取返回结果
    public Map<String, Object> getMap() {
        Map<String, Object> map = new HashMap<>();
        map.put("code", this.code);
        map.put("msg", this.msg);
        map.put("data", this.data);
        return map;
    }
}
